﻿@{
    ViewBag.Title = "For4";
}
<h1 data-bind="text: blogPostTitle"></h1>
<ul data-bind="foreach: people">
    <li>
        列表项:<b data-bind="text: name"></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;所属 <b data-bind="text: $parent.blogPostTitle"></b>
    </li>
</ul>


<script type="text/javascript">
    function AppViewModel() {
        var self = this;
        self.blogPostTitle = "列表标题";
        self.people = ko.observableArray([
        { name: 'Bert' },
        { name: 'Charles' },
        { name: 'Denise' }
        ]);

        self.addPerson = function () {
            self.people.push({ name: "New at " + new Date() });
        };

        self.removePerson = function () {
            self.people.remove(this);
        }
    }

    ko.applyBindings(new AppViewModel());
</script>
